package com.gsn.login;

import com.gsn.common.PortalCommingLayer;
import com.gsn.common.PortalDialogLayer;
import com.gsn.common.PortalDialogYesNoLayer.EButtonType;
import com.gsn.common.PortalDialogYesNoLayer.EDialogType;
import com.gsn.common.PortalDialogYesNoLayer.IDialogYesNoListener;
import com.gsn.common.PortalHelpLayer;
import com.gsn.dataCommon.UserData;
import com.gsn.engine.myplay.GsnGame;
import com.gsn.engine.myplay.GsnScreen;
import com.gsn.engine.utility.UtilityGettor;
import com.gsn.name.NameEdit;
import com.gsn.poker.asset.FontTexture;
import com.gsn.poker.asset.PortalTexture;
import com.gsn.poker.game.MyPoker;

public class LoginScreen extends GsnScreen implements IDialogYesNoListener {
	private static final String SHOW_DIALOG = "showDialog";
	public LoginLayer loginLayer;
	public PortalDialogLayer dialogLayer;
	public PortalCommingLayer commingLayer;
	public PortalHelpLayer helpLayer;

	public LoginScreen(float width, float height) {
		super(width, height);

	}

	@Override
	public void setDefaultInputListener() {
		loginLayer.setInputListener();
	}

	@Override
	public void onInit() {

		loginLayer = new LoginLayer(width, height);
		addLayer(loginLayer);

		dialogLayer = new PortalDialogLayer();
		dialogLayer.setDialogListener(LoginScreen.this);
		addLayer(dialogLayer);

		commingLayer = new PortalCommingLayer(width, height);
		addLayer(commingLayer, 1, false);

		helpLayer = new PortalHelpLayer(width, height);
		addLayer(helpLayer, 2, false);

	}

	@Override
	public void clickButton(String nameDlg, EButtonType btn) {
		// TODO Auto-generated method stub
		switch (btn) {
		case YES:
			if (nameDlg.equals(SHOW_DIALOG)) {
				UtilityGettor.inst().visibleTextField(NameEdit.NAME_USER);
				UtilityGettor.inst().visibleTextField(NameEdit.PASS_USER);
			}

			break;

		default:
			break;
		}
	}

	public void showCommingDialog() {
		// TODO Auto-generated method stub
		commingLayer.show();
	}

	public void showHelpDialog() {
		// TODO Auto-generated method stub
		helpLayer.show();
	}

	@Override
	protected void setAssetNeed() {
		addAsset(PortalTexture.inst());
		addAsset(FontTexture.inst());
	}

	@Override
	public GsnGame getGame() {
		// TODO Auto-generated method stub
		return MyPoker.game;
	}

	public void showDialogString(String s) {
		UtilityGettor.inst().hideTextField(NameEdit.NAME_USER);
		UtilityGettor.inst().hideTextField(NameEdit.PASS_USER);
		dialogLayer.createDialog(EDialogType.YES, SHOW_DIALOG, s);
		dialogLayer.show();
	}

}
